<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>菜品管理</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}

.navbar {
background-color: #d2a679;
overflow: hidden;
border-bottom: 2px solid #ccc;
}

.navbar a {
float: left;
display: block;
color: #000;
text-align: center;
padding: 14px 20px;
text-decoration: none;
font-size: 17px;
}

.navbar a:hover {
background-color: #ddd;
color: black;
}

.navbar a.active {
background-color: #ff704d;
color: white;
}

.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 0;
}

.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h1 {
margin-bottom: 20px;
color: #333;
text-align: center;
}

table {
width: 100%;
border-collapse: collapse;
}

table, th, td {
border: 1px solid #ccc;
}

th, td {
padding: 10px;
text-align: center;
}

tr:nth-child(even) {
background-color: #f2f2f2;
}

tr:hover {
background-color: #ddd;
}

form {
margin-top: 20px;
text-align: center;
}

input, textarea {
padding: 5px;
margin-bottom: 10px;
width: 60%;
display: block;
margin: 10px auto;
}

button {
padding: 5px 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>

<div class="navbar">
<a href="Order Status.jsp">点餐状态</a>
<a href="BOH.jsp">后厨状态</a>
<a href="order.jsp">今日订单</a>
<a href="Menu Management.jsp" class="active">菜品管理</a>
<a href="Sales Statistics.jsp">营业统计</a>
<a href="aboutme.jsp">我的</a>
</div>


<div class="container"> 

<h2>所有菜品名称价格</h2> 
<a href="edit.jsp">增加菜品</a>
<table width="100%" border="1">
<tr>
<th>ID</th> 
<th>菜品名称</th> 
<th>价格</th> 
<th width="10%">操作</th>
</tr>

<%

javax.sql.rowset.WebRowSet rs = com.myweb.DBTools.getRS("SELECT * FROM dishes");
while(rs.next()){
%>
<tr onclick="fillform(this)" style="cursor:pointer">
<td><%=rs.getString("dish_id")%></td>
<td><%=rs.getString("name")%></td>
<td><%=rs.getString("price")%></td>
<td>
<a href="edit.jsp?dish_id=<%=rs.getString("dish_id")%>">新增</a>
<a href="save.jsp?btn=del&dish_id=<%=rs.getString("dish_id")%>" class="button-delete" onclick="return confirm('请确认是否删除当前记录？');">删除</a> 
</td>
</tr>
<%
}
rs.close();
%>
</table> 

<hr>
<form action="save.jsp" method="post">

<label for="dish_id">dish_id</label>
<input type="text" id="dish_id" name="dish_id" readonly><br>
<label for="name">菜品名</label>
<input type="text" id="name" name="name" ><br>
<label for="price">价格</label>
<input type="text" id="price" name="price"><br>
<input type="submit" name="btn" value="修改">
<input type="submit" name="btn" value="新增"><br>

</form>

<script>
function fillform(row) {
document.forms[0].dish_id.value = row.children[0].innerText;
document.forms[0].name.value = row.children[1].innerText;
document.forms[0].price.value = row.children[2].innerText;
} 
</script>

</body>
</html>

